﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ra2map_plus.data
{
    class AppConfig
    {
        public List<string> defaultOutputDirs { set; get; }

        public string defaultRootIniFile { set; get; }

        public string defaultDistDir { set; get; }

        public string defaultDistFileName { set; get; }

        public List<string> defaultIncludeIniDirs { set; get; }
    
        public string defaultProjectConfigFileName { set; get; }

        public string textEditor { set; get; }

        public AppConfig fieldDesc { set; get; }

        public AppConfig()
        {
            this.defaultOutputDirs = new List<string>();
            this.defaultIncludeIniDirs = new List<string>();
        }

        public AppConfig mergeNonNullProperties(AppConfig otherAppConfig)
        {
            if (otherAppConfig.defaultOutputDirs != null && otherAppConfig.defaultOutputDirs.Count > 0)
            {
                this.defaultOutputDirs = otherAppConfig.defaultOutputDirs;
            }
            if (otherAppConfig.defaultIncludeIniDirs != null && otherAppConfig.defaultIncludeIniDirs.Count > 0)
            {
                this.defaultIncludeIniDirs = otherAppConfig.defaultIncludeIniDirs;
            }
            if (!string.IsNullOrWhiteSpace(otherAppConfig.defaultRootIniFile))
            {
                this.defaultRootIniFile = otherAppConfig.defaultRootIniFile;
            }
            if (!string.IsNullOrWhiteSpace(otherAppConfig.defaultDistDir))
            {
                this.defaultDistDir = otherAppConfig.defaultDistDir;
            }
            if (!string.IsNullOrWhiteSpace(otherAppConfig.defaultDistFileName))
            {
                this.defaultDistFileName = otherAppConfig.defaultDistFileName;
            }
            if (!string.IsNullOrWhiteSpace(otherAppConfig.defaultProjectConfigFileName))
            {
                this.defaultProjectConfigFileName = otherAppConfig.defaultProjectConfigFileName;
            }
            if (!string.IsNullOrWhiteSpace(otherAppConfig.textEditor))
            {
                this.textEditor = otherAppConfig.textEditor;
            }

            if (this.fieldDesc != null && otherAppConfig.fieldDesc != null)
            {
                this.fieldDesc.mergeNonNullProperties(otherAppConfig.fieldDesc);
            }
            return this;
        }
    }
}
